<?php if (!defined('THINK_PATH')) exit(); if($isAjax): ?><!DOCTYPE html>
<html>
    <head>
        <title><?php echo ($title); ?></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="generator" content="GodSon" />
        <meta name="author" content="LUCAS"/>
        <link rel="stylesheet" href="__ROOT____THM__/bootstrap/easyui.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="__ROOT____THM__/bootstrap/bootstrap.css"  type="text/css" media="screen" >

        <link rel="stylesheet" href="__ROOT____THM__/icon.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="__ROOT____CSS__/css.css" type="text/css" media="screen" />

        <script type="text/javascript" src="__ROOT____JS__/core/easyui1.4/jquery.min.js"></script>
        <script type="text/javascript" src="__ROOT____JS__/core/easyui1.4/jquery.easyui.min.js"></script>

        <script type="text/javascript" src="__ROOT____JS__/locale/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript" src="__ROOT____JS__/core/btutil.js"></script>
        <script type="text/javascript" src="__ROOT____JS__/My97DatePicker/WdatePicker.js"></script>



        <script>
            var _ROOT_ = '__ROOT__';
        </script>



    </head>
    <body>
        <div id="bt_loading" class="loading"></div>
        <div id="bt_loading_progress" class="progress">执行中...</div><?php endif; ?>
<div class="easyui-layout" fit="true">
    <div region="north" style="height: 70px;border-bottom: none;">
        <form id="bt_import_search_from">
            <table style="height: 100%;">
                <tr>
                    <td>手册号</td>
                    <td>
                        <input id="mm" class="easyui-combobox" name="Q_Custml_like"  style="width: 100px;" 
    data-options="valueField:'手册名称',textField:'手册名称',url:'__ROOT__/import/getmData'" /> 
                    </td>
                    <td>
                        <select class="easyui-combobox" data-options="panelHeight:'auto',editable:false,onChange:function(o,n){
                                if(o == '发票号'){$('#bt_import_input_name').attr('name','Q_inv_like')}else{
                                $('#bt_import_input_name').attr('name','Q_bgdh_like')
                                }
                                }">
                            <option>报关单号</option>
                            <option>发票号</option>
                        </select>
                    </td>
                    <td>
                        <input  type="text" name="Q_bgdh_like" id="bt_import_input_name"></td>
                    <td>品名</td>

                    <td>
                         <select id="Itemno" name="Q_Itemno_like" style="width:150px;"></select>
                    </td>

                    <td>运单号</td>
                    <td>
                        <input  type="text" name="Q_trackno_like"></td>
                    <td rowspan="2">
                        <a href="javascript:void(0)" class="easyui-linkbutton" id="bt_import_search_btn">查询</a>
                        <a href="javascript:$('#bt_import_search_from').form('clear');" class="easyui-linkbutton">清空</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        数量 <= </td>
                            <td>
                                <input  type="number" name="Q_QTY_ELT" style="width: 100px;"></td>
                            <td>邮件时间</td>

                            <td>
                                <input  class="easyui-datebox" type="text" name="Q_Mdate_EGT" value="<?php echo date('Y-m-d',time()-30000000);?>" maxDate="#F{ $dp.$D('bt_import_input_Mdate_ed')||'2014-10-1'}" id="bt_import_input_Mdate_st">
                            </td>
                            <td align="center">-</td>
                            <td>
                                <input class="easyui-datebox" type="text" name="Q_Mdate_ELT" }minDate="#F{ $dp.$D('bt_import_input_Mdate_st')}" id="bt_import_input_Mdate_ed"></td>

                        </tr>
                    </table>
                </form>
            </div>
            <div region="center"class="font-size:100px;" >
                <table id="bt_import_grid" ></table>
            </div>
            <div id="dd" ></div>
        </div>

        <script>
            $('#Itemno').combogrid({
                panelWidth:150,
                fitColumns:true,
                idField:'id',
                textField:'name',
                url:_ROOT_ + '/import/comboData',
                columns:[[
                    {field:'id',title:'ID',width:10},
                    {field:'name',title:'全称',width:20},
                ]]
            });
        </script>

        <script type="text/javascript"> NameSpace("BT.import", function() { var context = this; var $grid = $('#bt_import_grid');
<<<<<<< HEAD
var viewDialog=$('#dd');
=======
// var viewDialog=$('#dd');
var viewDialog=$('#dd');

>>>>>>> bb93f574d2920d1c8e97b349ba3546334497cbb6

context.ready = function() {
    $grid.datagrid({
        fit: true,
        border: true,
        nowrap: true,
        autoRowHeight: true,
        striped: true,
        collapsible:true,
        sortName: 'ID',
        sortOrder: 'desc',
        remoteSort: false,
        idField:'ID',
        url: _ROOT_ + '/import/getData',
        pagination: true,
        fitColumns:true,
        singleSelect:true,
        columns: [[
                {field:'ck',checkbox: true}, 
                {field: 'Mdate', title: '邮件时间' ,align:'center'},
                {field: 'Custml', title: '手册号' ,align:'center'},
                {field: '序号', title: '自编号' ,align:'center',sortable: true,formatter: function(value) {
                    return '<a href="/php-easyui/App/file/进口报关单/进口-'+ value + '.jpg" target="_blank" ><div id="nn">'+ value +'<div></a>';
                }},
                {field: 'bgdh', title: '报关单号' ,align:'center',sortable: true},
                {field: 'inv', title: '发票' ,align:'center', sortable: true},
                {field: 'trackno', title: '运单号' ,align:'center',formatter: function(value) {
                    return '<a href="/php-easyui/App/file/芯片发票/2014/'+ value + '.pdf" target="_blank" >'+ value +'</a>';
                }},
                {field: 'Idate', title: '进口时间' ,align:'center', sortable: true},
                 {field: 'Itemno', title: '料号' ,align:'center'},
                {field: 'name', title: '手册料号名' ,align:'center'},
                {field: 'Item', title: '品名' ,align:'center'},
                {field: 'QTY', title: '数量' ,align:'center',sortable: true},
                {field: 'amount', title: '金额' ,align:'center'},
                {field: 'Weight', title: 'Weight' ,align:'center'},
                {field: 'Rqty', title: 'Rqty' ,align:'center'},
                {field: 'Rdate', title: 'Rdate' ,align:'center', sortable: true},
                {field: '备注', title: '备注' ,align:'center'},
                {field: 'ID', title: '操作',  align: 'center', sortable: true,formatter: function(value) {
                                        return '<span title="编辑" class="img-btn icon-edit" ID=' + value + '></span>';
                }}
            ]],
        toolbar: [{
                text: '新增',
                iconCls: 'icon-add',
                handler: context.addView
            }, {
                text: '删除',
                iconCls: 'icon-remove',
                handler: context.doDelete
            }],
        // view: detailview,
        // detailFormatter:function(index,row){
        //             return '<div class="ddv" style="padding:5px 0"></div>';
        //         },
        //         onExpandRow: function(index,row){
        //             var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
        //             ddv.panel({
        //                 height:80,
        //                 border:false,
        //                 cache:false,
        //                 href:'datagrid21_getdetail.php?itemid='+row.itemid,
        //                 onLoad:function(){
        //                      $grid.datagrid('fixDetailRowHeight',index);
        //                 }
        //             });
        //              $grid.datagrid('fixDetailRowHeight',index);
        // },

        onLoadSuccess: function() {
            var $bodyView = $grid.data('datagrid').dc.view2;
            $bodyView.find('span[ID]').click(function(e) {
                e.stopPropagation();
                var uid = $(this).attr('ID');
                context.updateView(uid);
            });
        }
    });

    $('#bt_import_search_btn').click(function() {
        var map = $('#bt_import_search_from').toJson();
        for (var i = map.length - 1; i >= 0; i--) {
           alert(i.map[i]);
        };
        $grid.datagrid('load', $('#bt_import_search_from').toJson());
    });
};

context.addView = function() {

    viewDialog.dialog({
<<<<<<< HEAD
        title: '新增进口',
=======
        title: '新增订单',
        href: _ROOT_ + '/import/toadd',
>>>>>>> bb93f574d2920d1c8e97b349ba3546334497cbb6
        width: 400,
        height: 500,
        // closed: false,
        // cache: false,
        maximizable: true,
        resizable: true,
        bodyStyle: {overflow: 'hidden'},
        href: _ROOT_ + '/import/toadd',
        buttons: [{
                text: '提交',
                handler: context.doSubmit
            }],
        modal: true
    });
};

context.updateView = function(id) {
    r= $grid.datagrid('getRowIndex',id);
    viewDialog.dialog({
        title: '编辑进口清单',
        href: _ROOT_ + '/import/toUpdate?ID=' + id,
        width: 400,
        height: 500,
        maximizable: true,
        resizable: true,
        bodyStyle: {overflow: 'hidden'},
        buttons: [{
                text: '上一条',
                handler: function(){
                    viewDialog.dialog('close');
                    $grid.datagrid('clearSelections',r);
                    if(r>0)r=r-1;$grid.datagrid('selectRow',r);
                    var selected=$grid.datagrid('getSelected');
                    id=selected.ID;
                    context.updateView(id);
                }
            },{
                text: '下一条',
                handler:function(){
                    viewDialog.dialog('close');
                    $grid.datagrid('clearSelections',r);
                    if(r<$grid.datagrid('getRows').length-1)r=r+1;
                    $grid.datagrid('selectRow',r);
                    var selected=$grid.datagrid('getSelected');
                    id=selected.ID;
                    context.updateView(id);
                }
            },{
                text: '提交',
                handler:function(){
                        $bt_import_from = $('#bt_import_from');
                        if ($bt_import_from.form('validate')) {
                        $.post(_ROOT_ + '/import/doSave2', $bt_import_from.toJson(), function(rsp) {
                                if (rsp.status) {
                                    $grid.datagrid('reload');
                                    // viewDialog.dialog('close');
                                    // $grid.datagrid('clearSelections',r);
                                    // if(r>0)r=r-1;$grid.datagrid('selectRow',r);
                                    // var selected=$grid.datagrid('getSelected');
                                    // id=selected.ID;
                                    // context.updateView(id);
                                } else {
                                    $.alert(rsp.msg+'修改失败！');
                                }
                        }, "JSON");
                        }
                }
            }]
    });
};


context.doDelete = function() {
    var checked = $grid.datagrid('getChecked');
    if (checked && checked.length > 0) {
        $.confirm('确认删除？', function(r) {
            if (r) {
                var ids = [];
                $.each(checked, function() {
                    ids.push(this.uid);
                });
                $.post(_ROOT_ + '/import/doDelete', {ids: ids.join(',')}, function(rsp) {
                    if (rsp.status) {
                        $grid.datagrid('reload');
                    } else {
                        $.alert(rsp.msg);
                    }
                }, 'JSON');
            }
        });
    }
};

context.doSubmit = function(){
    $bt_import_from = $('#bt_import_from');
    if ($bt_import_from.form('validate')) {
        $.post(_ROOT_ + '/import/doSave2', $bt_import_from.toJson(), function(rsp) {
            if (rsp.status) {
                $grid.datagrid('reload');
                $.alert('修改成功！');
                viewDialog.dialog('close');
            } else {
                $.alert(rsp.msg+'修改失败！');
                viewDialog.dialog('close');
            }
        }, "JSON");
    }

};
 }); </script>